{% extends 'front/front_base.html' %}

{% block title %}首页{% endblock %}

{% block main_content %}
    <div class="main-container">
        <div class="cl-container">
            <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
                <!-- Indicators 指令 -->
                <ol class="carousel-indicators">
                    {% for banner in banners %}
                        {% if loop.first %}
                            <li data-target="#carousel-example-generic" data-slide-to="{{ loop.index0 }}"
                                class="active"></li>
                        {% else %}
                            <li data-target="#carousel-example-generic" data-slide-to="{{ loop.index0 }}"></li>
                        {% endif %}
                    {% endfor %}
                </ol>

                <!-- Wrapper for slides 轮播图 -->
                <div class="carousel-inner" role="listbox">
                    {% for banner in banners %}
                        {% if loop.first %}
                            <div class="item active">
                                <img src="{{ banner.image_url }}" alt="{{ banner.name }}"
                                     style="width: 400px; height: 240px">
                                <div class="carousel-caption">
                                    {{ banner.name }}
                                </div>
                            </div>
                        {% else %}
                            <div class="item">
                                <img src="{{ banner.image_url }}" alt="{{ banner.name }}"
                                     style="width: 400px; height: 240px">
                                <div class="carousel-caption">
                                    {{ banner.name }}
                                </div>
                            </div>
                        {% endif %}


                    {% endfor %}
                    ...
                </div>

                <!-- Controls 左右切换控制 -->
                <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
                    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                    <span class="sr-only">Previous</span>
                </a>
                <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
                    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                    <span class="sr-only">Next</span>
                </a>
            </div>

            <div class="post-group">
                <ul class="post-group-head">
                    {% if current_sort == 1 %}
                        <li class="active"><a href="{{ url_for('front.index', st=1, board_id=current_board) }}">最新</a></li>
                    {% else %}
                        <li class=""><a href="{{ url_for('front.index', st=1, board_id=current_board) }}">最新</a></li>
                    {% endif %}

                    {% if current_sort == 2 %}
                        <li class="active"><a href="{{ url_for('front.index', st=2, board_id=current_board) }}">精华帖子</a></li>
                    {% else %}
                        <li class=""><a href="{{ url_for('front.index', st=2, board_id=current_board) }}">精华帖子</a></li>
                    {% endif %}
                    {% if current_sort == 3 %}
                        <li class="active"><a href="{{ url_for('front.index', st=3, board_id=current_board) }}">点赞最多</a></li>
                    {% else %}
                        <li class=""><a href="{{ url_for('front.index', st=3, board_id=current_board) }}">点赞最多</a></li>
                    {% endif %}
                    {% if current_sort == 4 %}
                        <li class="active"><a href="{{ url_for('front.index', st=4, board_id=current_board) }}">评论最多</a></li>
                    {% else %}
                        <li class=""><a href="{{ url_for('front.index', st=4, board_id=current_board) }}">评论最多</a></li>
                    {% endif %}
                </ul>
                <ul class="post-list-group">
                    {% for post in posts %}
                        <li>
                            <div class="author-avatar-group">
                                <img src="#" alt="">
                            </div>
                            <div class="post-info-group">
                                <p class="post-title">
                                    <a href="{{ url_for('front.post_detail', post_id=post.id) }}"
                                       target="_blank">{{ post.title | truncate(20) }}</a>
                                    {% if post.highlight %}
                                        <span class="label label-danger">精华帖</span>
                                    {% endif %}
                                </p>
                                <p class="post-info">
                                    <span>作者：{{ post.author.username | truncate(6) }}</span>
                                    <span>发表时间：{{ post.create_time }}</span>
                                    <span>阅读：{{ post.read_count }}</span>
                                    <span>点赞：{{ post.like_count }}</span>
                                    <span>评论：{{ post.comment_count }}</span>
                                </p>
                            </div>
                        </li>
                    {% endfor %}

                </ul>
                <div style="text-align:center;">
                    {{ pagination.links }}
                </div>
            </div>
        </div>

        <div class="sm-container">
            <div style="padding-bottom:10px;">
                <a href="{{ url_for('front.apost') }}" class="btn btn-warning btn-block">发布帖子</a>
            </div>
            <div class="list-group">
                {% if show_all %}
                    <a href="{{ url_for('front.index', st=current_sort) }}" class="list-group-item active">所有板块</a>
                {% else %}
                    <a href="{{ url_for('front.index', st=current_sort) }}" class="list-group-item">所有板块</a>
                {% endif %}

                {% for board in boards %}
                    {% if current_board == board.id %}
                        <a href="{{ url_for('front.index', st=current_sort, board_id=board.id) }}"
                           class="list-group-item active">{{ board.name }}</a>
                    {% else %}
                        <a href="{{ url_for('front.index', st=current_sort, board_id=board.id) }}"
                           class="list-group-item">{{ board.name }}</a>

                    {% endif %}
                {% endfor %}
            </div>
        </div>
    </div>
{% endblock %}